package jdbc;

import java.sql.*;

public class DataBaseConnection {

	Connection con;

	public Boolean Conectar(){
		String url="jdbc:oracle:thin:@192.168.233.129:1521";
		String user="root";
		String pass="root";
		try {
			//Registra los drivers
			DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

			// Conexion a la basRe de datos
			this.con = DriverManager.getConnection(url, user, pass);

			return true;
		}
		catch (SQLException e) {
			return false;

		}
		
	}

	public boolean Desconectar(){
		try {
			con.close();
			return true;
		} catch (SQLException e) {
			return false;
		}
	}

	private Statement CreateStatement(){
		try {
			return con.createStatement();
		} catch (SQLException e) {
			return null;
		}
	}
	
	public ResultSet ExecuteQuery(String query){
		Statement st=CreateStatement();
		try {
			ResultSet rs=st.executeQuery(query);
			return rs;
		} catch (SQLException e) {
			return null;
		}
		
		
	}
}

